import { userAPI } from './api'
import store from '../store'

//服务器地址
//const baseServer = 'http://47.98.54.250/myDisk';
const baseServer = 'http://localhost:8080/myDisk';

//接口基路径
const baseUrl = 'http://47.98.54.250/api';

//上传路径
const simpleUploadURL = baseUrl + '/file/uploadPart';

/**
 * 全局恢复state 页面刷新数据恢复
 */
const recoverState = async () => {
  let userInfo = store.getters.getUserInfo
  if (!userInfo.id) {
    try {
      let res = await userAPI.common.info()
      store.commit('setUserInfo', res.data.userInfo);
    } catch (err) {
      console.log(err);
    }
  }
}

export { baseServer, baseUrl, simpleUploadURL, recoverState }